function [f] = fobj_svr(Z, W, eta, X, y, alphav, invsigmawsqr, invsigmaetasqr, invsigmaxsqr, tnidx, C, ell)
% -log(prior)
f = (0.5*invsigmawsqr)*norm(W, 'fro')^2 + numel(W)*log(sqrt(2*pi/invsigmawsqr)) + ...
    (0.5*invsigmaetasqr)*norm(eta, 'fro')^2 + numel(eta)*log(sqrt(2*pi/invsigmaetasqr)) - ...
    logpibp(Z, alphav);

% -log(likelihood)
f = f + 0.5*invsigmaxsqr*norm(X-Z*W', 'fro')^2;

% +emperical loss
for m = 1:numel(tnidx)-1
    nind = tnidx(m):tnidx(m+1)-1;
    f = f + C*sum(max(abs(y(nind)'-(eta(m,:)*Z'*X(:,nind))) - ell, 0));
end
